#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "eagle.h"

static void CanFly(struct Bird *Bird, const BOOL Fly)
{
    if(Bird == NULL){
        return;
    }

    struct Eagle *Eagle = (struct Eagle *)Bird;
    Eagle->Fly = Fly;
}

static void CanEateMeat(struct Bird *Bird, const BOOL EateMeat)
{
    if(Bird == NULL){
        return;
    }

    struct Eagle *Eagle = (struct Eagle *)Bird;
    Eagle->EateMeat = EateMeat;
}

static BOOL IsFly(struct Bird *Bird)
{
    if(Bird == NULL){
        return FALSE;
    }

    struct Eagle *Eagle = (struct Eagle *)Bird;
    return Eagle->Fly;
}

static BOOL IsEateMeat(struct Bird *Bird)
{
    if(Bird == NULL){
        return FALSE;
    }

    struct Eagle *Eagle = (struct Eagle *)Bird;
    return Eagle->EateMeat;
}

static void LayEggs(struct Bird *Bird)
{
    if(Bird == NULL){
        return;
    }

    printf("Eagle lay eggs\n");
}

void EagleInit(struct Eagle *Eagle)
{
    if(Eagle == NULL){
        return;
    }
    BirdInit(&Eagle->Bird);
    Eagle->CanFly = CanFly;
    Eagle->CanEateMeat = CanEateMeat;
    Eagle->IsFly = IsFly;
    Eagle->IsEateMeat = IsEateMeat;

    Eagle->Bird.LayEggs = LayEggs;

    Eagle->CanFly((struct Bird *)Eagle, TRUE);
    Eagle->CanEateMeat((struct Bird *)Eagle, TRUE);
}

void EagleDeinit(struct Eagle *Eagle)
{
    if(Eagle == NULL){
        return;
    }
    memset(Eagle, 0, sizeof(struct Eagle));
    BirdDeinit(&Eagle->Bird);
}